<?php
if(!$_GET['cgp'] || $_GET['cgp']!='225800') {
    exit('Access Denied');
}
?>
<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <title>产品同示例表单</title>
</head>
<body>
<form id="ourFrm" action="" method="post">
    <input name="action" type="hidden" value="sync_land"/>
    <p>会员ID: <input type="number" name="mid" /></p>
    <p>景区ID: <input type="number" name="lid" /> </p>
    <p><button type="button" id="BtnSubmit">提交</button></p>
</form>
<div style="width:500px;border:1px solid #ddd; background-color: #B5EEAC;" id="result">

</div>
<script src="http://cdn.staticfile.org/jquery/1.9.0/jquery.min.js"></script>
<script>
    function jsonCall(res) {
        console.log(res);
        alert(res['msg']);
        if(res['status']=='ok') {
            $("#result").text($res['msg']);
        }
    }
    $(document).ready(function(){
        $("#BtnSubmit").on('click', function(){
            $.getJSON('/module/sync/index.php', $("#ourFrm").serialize())
                .done(function(res){
                    console.log(res);
                    if(res.status=='ok') {
                        //console.log('get remote');
                        $("#result").html(res['msg']);
                        var params = {
                            'action':'create_land',
                            'lid':$("input[name='lid']").val(),
                            'mid':res['mid'],
                            callback:'jsonCall'
                        };
                        $.getJSON('http://www.16u.cc/d/module/sync/index.php?callback=?', params);
                    } else {
                        $("#result").html(res.msg);
                    }
                });
        });

    });
</script>
</body>
</html>